package com.anjie.powerproject.strategy.pojo.device;

import java.util.Arrays;

/**
 * 储能设备
 */
public class StorageDevice extends com.anjie.powerproject.strategy.pojo.device.SupplyDevice {
    // 放能系数
    private double coefficient;
    // 所依赖的放能设备
    private com.anjie.powerproject.strategy.pojo.device.SupplyDevice relDevice;

    public StorageDevice(Integer id, String name, com.anjie.powerproject.strategy.pojo.device.SupplyDevice relDevice, int len, double coefficient) {
        super(id, name, len);
        this.relDevice = relDevice;
        relDevice.setStoragyDeviceName(name);
        this.coefficient = coefficient;
    }

    public StorageDevice(BaseDevice device, int len, double coefficient) {
        super(device, len);
        this.coefficient = coefficient;
    }

    public boolean hasStorage() {
        return Arrays.stream(getFlag()).filter(item->item==2).sum() > 0;
    }

    public String getStorageInfo() {
        return getName() + "蓄能";
    }

    public void setRelDevice(com.anjie.powerproject.strategy.pojo.device.SupplyDevice relDevice) {
        this.relDevice = relDevice;
        relDevice.setStoragyDeviceName(getName());
    }

    public com.anjie.powerproject.strategy.pojo.device.SupplyDevice getRelDevice() {
        return relDevice;
    }

    public double getCoefficient() {
        return coefficient;
    }

    public void setCoefficient(double coefficient) {
        this.coefficient = coefficient;
    }
}